class Department < ActiveRecord::Base
  has_many :auditor
  has_many :applicant
  belongs_to :manager,:class_name => 'Applicant',:foreign_key => 'manager_id'

  def self.findAll pageBegin,pageEnd
    find(:all,:offset=>pageBegin.to_i,:limit =>pageEnd.to_i)
  end

  def self.findDepartmentOfBar name,pageBegin,pageEnd
        name =  name.to_s
    find(:all,:conditions => ['name like ?','%'+name+'%'],:offset=>pageBegin.to_i,:limit =>pageEnd.to_i)
  end
    def self.findDepartmentOfCount name
        name =  name.to_s
    find(:all,:conditions => ['name like ?','%'+name+'%'])
  end
end
